package dao.interf;

import java.util.List;
import java.util.Map;

public interface IBaseDAO<T> {
	/**
	 * 查找单个对象 通过id
	 * @param id
	 * 			参数id
	 * @return
	 * @throws RuntimeException
	 */
	public T findById(Object id) throws RuntimeException;
	/**
	 * 查找一组对象 通过规则
	 * @return 实体数组
	 * @throws RuntimeException
	 */
	public List<T> findAll() throws RuntimeException;
	
	/**
	 * 保存对象
	 * @param entity
	 * 			实体
	 * @return
	 * @throws RuntimeException
	 */
	public T save(T entity) throws RuntimeException;
	
	/**
	 * 删除对象
	 * @param entity
	 * @throws RuntimeException
	 */
	public void del(T entity) throws RuntimeException;
	
	
	public void delById(Object id) throws RuntimeException;
	
	/**
	 * 批量删除
	 * @param entities
	 * @throws RuntimeException
	 */
	public void batchDel(List<T> entities) throws RuntimeException;
	
	/**
	 * 全部删除
	 * @throws RuntimeException
	 */
	public void delAll() throws RuntimeException;
	
	
	/**
	 * 更新对象
	 * @param entity
	 * @return
	 * @throws RuntimeException
	 */
	public T update(T entity) throws RuntimeException;
	
	/**
	 * 批量删除
	 * @param entities
	 * @throws RuntimeException
	 */
	public void batchUpdate(List<T> entities) throws RuntimeException;
	
	/**
	 * 批量添加对象
	 * @param entities
	 * @throws RuntimeException
	 */
	public void batchAdd(List<T> entities) throws RuntimeException;
	
	public void batchSave(List<T> entities) throws RuntimeException;
	
	public Integer getAllCount() throws RuntimeException;
	
	/**
	 * 通过属性查找（按规则排序）
	 * @param pNames
	 * @param pValues
	 * @return
	 * @throws RuntimeException
	 */
	public List<T> findByProperties(String[] pNames, Object[] pValues)
			throws RuntimeException;
	
	public List<T> findByProperties(final Map<String,Object> map) throws RuntimeException;
	
	public int delByProperties(final Map<String,Object> map) throws RuntimeException;
	/**通过
	 * 
	 * @param queryString
	 * @return
	 * @throws RuntimeException
	 */
	public List<T> find(String queryString) throws RuntimeException;
	
	public List<T> find(String queryString, Object[] pValues) throws RuntimeException;
	
	
}
